package com.xxgc.location.controller;

import com.xxgc.location.po.LocationPO;
import com.xxgc.location.websocket.LocationWS;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 接收用户位置信息
 */

@RestController
@RequestMapping("/location")
public class LocationController {
    //接收用户发过来的经纬度
    @PostMapping("/getLocation")
    public String getLocation(String latitude, String longitude) {
        //封装到PO内
        LocationPO locationPO = new LocationPO();
        locationPO.setLatitude(latitude);
        locationPO.setLongitude(longitude);
        //发送到websocket
        LocationWS.sendMessage(locationPO);
        System.out.println("我收到了");
        return "success";
    }
}
